﻿using UnityEngine;

public class Battle : MonoBehaviour {
	private static Battle g_Battle = null;
	private BattleInfo _battleInfo;

	void Awake()
	{
		g_Battle = this;
	}

	void Start () {
		OnEnter ();
	}

	void OnDestroy()
	{
		g_Battle = null;
	}

	#region API
	public static Battle Instance{
		get {
			return g_Battle;
		}
	}

	public static Battle Create(BattleInfo battleInfo)
	{
		if (Instance != null) {
			Debug.LogWarning("[Battle]战场已经存在，请检查是否重复创建！");	
			return Instance;
		}

		GameObject battleObj = new GameObject("Battle");
		g_Battle = battleObj.AddComponent<Battle>();
		g_Battle.initWith(battleInfo);
		return g_Battle;
	}

	public void initWith(BattleInfo battleInfo)
	{
		_battleInfo = battleInfo;
	}

	public void pause()
	{
		Time.timeScale = 0;
		OnPause();
	}
	#endregion

	#region Battle life time
	void OnEnter()
	{

	}

	void OnStart()
	{

	}

	void OnPause()
	{

	}

	void OnStop()
	{

	}

	void OnExit()
	{

	}
	#endregion
}
